Skip to content

lf-queue: Rewrite based on Nikolaev's paper and hazard pointers #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

csm1735
Copy link
Contributor

@csm1735 csm1735 commented Jun 20, 2023

Instead of using the old implementation, a concurrent queue 'lfq' is provided, which can utilize hazard pointers to release memory.

The program has been rewritten using C11 Atomics to support other processor architectures, and it has solved the data race issues, enabling it to pass the runtime detection of Thread Sanitizer.

#define ATOMIC_RELEASE atomic_flag_clear

#define ATOMIC_SUB atomic_fetch_sub
#define ATOMIC_SUB64 ATOMIC_SUB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATOMIC_SUB64 is not really used. Drop it.

lf-queue/lfq.c Outdated
struct lfq_node *p = ctx->fph;
if ((!atomic_load(&p->can_free)) || (!atomic_load(&p->free_next)) ||
in_hp(ctx, (struct lfq_node *) p))
goto final;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using goto, can you simply use break statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@jserv jserv changed the title lf-queue: Replace the old lf-queue with lfq lf-queue: Rewrite based on Nikolaev's paper and hazard pointers Jun 21, 2023
@@ -1,8 +1,5 @@
# Multithreaded Bounded Lock-free Queue
# lfq
The lock-free queue implemented is based on the paper [A Scalable, Portable, and Memory-Efficient Lock-Free FIFO Queue](https://drops.dagstuhl.de/opus/volltexte/2019/11335/pdf/LIPIcs-DISC-2019-28.pdf) by Ruslan Nikolaev.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "implemented" with "implementation."

Instead of using the old implementation, a concurrent queue based
on Nikolaev's paper and hazard pointers is provided.

The program has been rewritten using C11 Atomics to support other
processor architectures, and it has solved the data race issues,
enabling it to pass the runtime detection of Thread Sanitizer.
@jserv jserv merged commit 887cf80 into sysprog21:master Jun 22, 2023
@jserv
Copy link
Contributor

jserv commented Jun 22, 2023

Thank @csm1735 for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants